package com.sv.zgydor.dao.impl;

import com.sv.zgydor.dao.ProjectDAO;
import com.sv.zgydor.pojo.pg.TProjectListEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Class summary
 * User: kevin
 * Date: 2017/09/19
 * Time: 17:24
 * Description:
 */
@Repository
public class ProjectDAOImpl extends BaseDAOImpl implements ProjectDAO {

    @Override
    public List<TProjectListEntity> findAllProjects(){
        String hql = "from TProjectListEntity t";
        return this.pgDSGSessionFactory.getCurrentSession().createQuery(hql).list();
    }

    /**
     * 根据Id查询一个项目对象
     *
     * @param pid 主键
     * @return 一个项目对象
     */
    @Override
    public TProjectListEntity findProjectById(int pid) {
        String hql = "from TProjectListEntity t where t.pid=:pid";
        return (TProjectListEntity)this.pgDSGSessionFactory.getCurrentSession().createQuery(hql).setParameter("pid",pid).uniqueResult();
    }
}
